class Solution {
public:
    vector<vector<int>> reconstructQueue(vector<vector<int>>& people) {
        sort(people.begin(), people.end(), [](const vector<int>& x, const vector<int>& y)
            {
                return x[0] != y[0] ? x[0] > y[0] : x[1] < y[1];
            });
        vector<vector<int>> ans;
        for (auto e : people)
        {
            ans.insert(ans.begin() + e[1], e);
        }
        return ans;
    }
};